package cn.cjj.gulimall.search.controller;

import cn.cjj.common.exception.BizCodeEnume;
import cn.cjj.common.to.es.SkuEsModel;
import cn.cjj.common.utils.R;
import cn.cjj.gulimall.search.service.ElasticSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author CuiJunJie
 * @create 2021/6/21-15:39
 */
@RequestMapping("/search/save")
@RestController
public class ElasticSaveController {

    @Autowired
    ElasticSaveService elasticSaveService;


    @RequestMapping("/product")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels) {
        boolean b;
        try {
            System.out.println("/search/save/product");
            b = elasticSaveService.productStatusUp(skuEsModels);
        } catch (Exception e) {
            System.out.println(e);
            return R.error();
        }

        if (b) {
            return R.ok();
        } else {
            return R.error();
        }
    }
}
